package com.xinyan.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.xinyan.pojo.SprayAdCategory;
import com.xinyan.service.ISprayAdCategoryService;
import com.xinyan.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xzlf
 * @since 2024-03-19 17:57:43
 */
@RestController
@RequestMapping("/ad")
public class SprayAdCategoryController {

    @Autowired
    private ISprayAdCategoryService sprayAdCategoryService;

    @GetMapping("/findByPage")
    public R findByPage(@RequestParam(defaultValue = "1") long page, @RequestParam(defaultValue = "10") long size){
        PageDTO<SprayAdCategory> byPage = sprayAdCategoryService.findByPage(page, size);

        return R.ok(byPage);
    }


    @PostMapping("/updateById")
    public R updateById(@RequestBody SprayAdCategory adCategory){
        sprayAdCategoryService.updateById(adCategory);
        return R.ok();
    }

    @PostMapping("/addAdCategory")
    public R addAdCategory(@RequestBody SprayAdCategory adCategory){
        sprayAdCategoryService.addAdCategory(adCategory);
        return R.ok();
    }

    @GetMapping("/deleteAdCategory")
    public R deleteAdCategory(int id){
        sprayAdCategoryService.deleteAdCategory(id);
        return R.ok();
    }

}
